Skip to content

don't set header origin if using an agent #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2018
Merged

don't set header origin if using an agent #1179

merged 1 commit into from
Apr 26, 2018

Conversation

sks
Copy link
Contributor

@sks sks commented Apr 26, 2018

Sample vue.config.json

const HttpsProxyAgent = require('https-proxy-agent');


let agent
const proxyServer = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
if (proxyServer) {
  agent = new HttpsProxyAgent(proxyServer)
}

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target:"https://www.example.com",
        agent: agent,
        logLevel: process.env.DEBUG
      }
    }
  }
}

Was running into error

_http_outgoing.js:491
    throw new Error('Can\'t set headers after they are sent.');
    ^

Error: Can't set headers after they are sent.
    at validateHeader (_http_outgoing.js:491:11)
    at ClientRequest.setHeader (_http_outgoing.js:498:3)
    at ProxyServer.onProxyReq (MY_PROJECT_PATH/node_modules/@vue/cli-service/lib/util/prepareProxy.js:90:20)
    at ProxyServer.emit (MY_PROJECT_PATH/node_modules/eventemitter3/index.js:119:35)
    at ClientRequest.<anonymous> (MY_PROJECT_PATH/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:125:27)
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at tickOnSocket (_http_client.js:657:7)
    at onSocketNT (_http_client.js:673:5)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

So adding the line fixed the issue

@yyx990803 yyx990803 merged commit 79bc088 into vuejs:dev Apr 26, 2018
@sks sks deleted the patch-1 branch April 26, 2018 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants